﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LevelEditor.View.UserControls
{
    /// <summary>
    /// Logique d'interaction pour NavigatorPanel.xaml
    /// </summary>
    public partial class NavigatorPanel : UserControl
    {
        //Events
        public event EventHandler ZoomValueChanged;

        private void OnZoomValueChanged()
        {
            if (ZoomValueChanged != null)
                ZoomValueChanged(null, new EventArgs());
        }

        //Properties
        public double ZoomValue
        {
            get
            {
                return zoomSlider.Value;
            }
            set
            {
                zoomValue.Text = zoomSlider.Value + "%";
                zoomValue.Text = "100%";
            }
        }

        public RenderTargetBitmap PreviewImage
        {
            set {
                previewImage.Stretch = Stretch.Uniform;
                previewImage.Source = value;

                previewImage.Width = this.Width;
                previewImage.MaxHeight = 100;

                previewImage.InvalidateVisual();
                previewImageBorder.InvalidateVisual();
            }
        }

        public NavigatorPanel()
        {
            InitializeComponent();

            ZoomValue = 100;

            zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(zoomSlider_ValueChanged);
        }

        //Event Handlers

        protected void zoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            zoomValue.Text = zoomSlider.Value + "%";
            OnZoomValueChanged();
        }
    }
}
